<style>
    #test + .layui-table-view .layui-table-body tbody > tr > td {
        padding: 0;
    }

    #test + .layui-table-view .layui-table-body tbody > tr > td > .layui-table-cell {
        height: 110px;
    }
</style>

<body>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 表格工具栏 -->
            <form class="layui-form toolbar">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <select name="field_name" lay-verify="required" required>
                            <option value="id">用户ID</option>
                            <option value="account">账号</option>
                            <option value="mobile">手机号码</option>
                        </select>
                    </div>
                    <div class="layui-inline">
                        <input name="field_value" class="layui-input" placeholder="输入搜索内容"/>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <select name="level_id">
                                <option value="">选择会员等级</option>
                                {{volist name="level_list" id="item"}}
                                <option value="{{$item.id}}">{{$item.level_name}}</option>
                                {{/volist}}
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <select name="date_type" lay-verify="required" required>
                            <option value="created_at">注册时间</option>
                        </select>
                    </div>
                    <div class="layui-inline">
                        <input type="text" autocomplete="off" id="startDate" name="start_date" class="layui-input"
                               placeholder="开始日期">
                    </div>
                    <div class="layui-inline">
                        <input type="text" autocomplete="off" id="endDate" name="end_date" class="layui-input"
                               placeholder="结束日期">
                    </div>
                    <div class="layui-inline">&emsp;
                        <button class="layui-btn icon-btn" lay-filter="search" lay-submit>
                            <i class="layui-icon">&#xe615;</i>搜索
                        </button>
                    </div>
                </div>
            </form>
            <!-- 数据表格 -->
            <table id="test" lay-filter="test"></table>
        </div>
    </div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn layui-btn-xs" lay-event="recharge">充值</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="reduce">扣款</a>
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    {{# if(d.status == 0) { }}
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="thaw">冻结</a>
    {{# }else{ }}
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="freeze">解冻</a>
    {{# } }}
    <br>
    <a class="layui-btn layui-btn layui-btn-xs" lay-event="rixibao">修改日息宝金额</a>
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="editBankCard">修改银行卡</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delBankCard">删除银行卡</a>
    <br>
    <a class="layui-btn layui-btn-xs" lay-event="addUserAuth">添加实名认证</a>
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="saveRechargeDialog">
    <form id="saveRechargeForm" lay-filter="saveRechargeForm" class="layui-form model-form">
        <input type="hidden" name="id">
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">充值金额</label>
            <div class="layui-input-block">
                <input name="money" placeholder="请输入充值金额" class="layui-input"
                       lay-verType="tips" lay-verify="required|money" autocomplete="off" required/>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn" lay-filter="saveRechargeSubmit" lay-submit>保存</button>
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </form>
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="saveReduceDialog">
    <form id="saveReduceForm" lay-filter="saveReduceForm" class="layui-form model-form">
        <input type="hidden" name="id">
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">扣减金额</label>
            <div class="layui-input-block">
                <input name="money" placeholder="请输入扣减金额" class="layui-input"
                       lay-verType="tips" lay-verify="required|money" autocomplete="off" required/>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn" lay-filter="saveReduceSubmit" lay-submit>保存</button>
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </form>
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="saveRixibaoDialog">
    <form id="saveRixibaoForm" lay-filter="saveRixibaoForm" class="layui-form model-form">
        <input type="hidden" name="id">
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required" style="width: 100px;">日息宝金额</label>
            <div class="layui-input-block">
                <input name="money" placeholder="请输入日息宝金额,支持2位小数" class="layui-input"
                       lay-verType="tips" lay-verify="required|money" autocomplete="off" required style="width: 94%"/>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn" lay-filter="saveRixibaoSubmit" lay-submit>保存</button>
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </form>
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="saveUserDialog">
    <form id="saveUserForm" lay-filter="saveUserForm" class="layui-form model-form">
        <input type="hidden" name="id">
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">账户</label>
            <div class="layui-input-block">
                <input name="account" disabled class="layui-input layui-disabled" autocomplete="off" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机号码</label>
            <div class="layui-input-block">
                <input name="mobile" class="layui-input" autocomplete="off" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">登录密码</label>
            <div class="layui-input-block">
                <input type="password" name="password" class="layui-input" autocomplete="off" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">支付密码</label>
            <div class="layui-input-block">
                <input type="password" name="pay_password" class="layui-input" autocomplete="off" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">会员等级</label>
            <div class="layui-input-block">
                <select name="level_id" lay-verify="required" required>
                    <option value="">选择用户等级</option>
                    {{volist name="level_list" id="item"}}
                    <option value="{{$item.id}}">{{$item.level_name}}</option>
                    {{/volist}}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">冻结状态</label>
            <div class="layui-input-block">
                <select name="status" lay-verify="required" required>
                    <option value="0">正常</option>
                    <option value="1">冻结</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item text-right">
            <button class="layui-btn" lay-filter="saveUserSubmit" lay-submit>保存</button>
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </form>
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="addUserDialog">
    <form id="addUserForm" lay-filter="addUserForm" class="layui-form model-form">
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">账户</label>
            <div class="layui-input-block">
                <input name="account" lay-verType="tips" lay-verify="required" class="layui-input" autocomplete="off"
                       required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机号码</label>
            <div class="layui-input-block">
                <input name="mobile" class="layui-input" autocomplete="off" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">登录密码</label>
            <div class="layui-input-block">
                <input type="password" lay-verType="tips" lay-verify="required|money" name="password"
                       class="layui-input" autocomplete="off" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">支付密码</label>
            <div class="layui-input-block">
                <input type="password" lay-verType="tips" lay-verify="required|money" name="pay_password"
                       class="layui-input" autocomplete="off" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">会员等级</label>
            <div class="layui-input-block">
                <select name="level_id" lay-verify="required" required>
                    <option value="">选择用户等级</option>
                    {{volist name="level_list" id="item"}}
                    <option value="{{$item.id}}">{{$item.level_name}}</option>
                    {{/volist}}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-form-required">冻结状态</label>
            <div class="layui-input-block">
                <select name="status" lay-verify="required" required>
                    <option value="0">正常</option>
                    <option value="1">冻结</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item text-right">
            <button class="layui-btn" lay-filter="addUserSubmit" lay-submit>保存</button>
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </form>
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="saveBankCardDialog">
    <form id="saveBankCardForm" lay-filter="saveBankCardForm" class="layui-form model-form">
        <input type="hidden" name="id">
        <div class="layui-form-item">
            <label class="layui-form-label">持卡人姓名
            </label>
            <div class="layui-input-block">
                <input name="username" placeholder="持卡人姓名最多100个字符" class="layui-input"
                       lay-verType="tips" lay-verify="username" autocomplete="off" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">卡号</label>
            <div class="layui-input-block">
                <input name="number" placeholder="卡号最多100个字符" class="layui-input"
                       lay-verType="tips" lay-verify="number" autocomplete="off" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">银行名称</label>
            <div class="layui-input-block">
                <input name="bank_name" placeholder="银行名称最多100个字符" class="layui-input"
                       lay-verType="tips" lay-verify="bank_name" autocomplete="off" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">支行名称</label>
            <div class="layui-input-block">
                <input name="bank_branch_name" placeholder="支行名称最多100个字符" class="layui-input"
                       lay-verType="tips" lay-verify="bank_branch_name" autocomplete="off" required/>
            </div>
        </div>

        <div class="layui-form-item text-right">
            <button class="layui-btn" lay-filter="saveBankCardSubmit" lay-submit>保存</button>
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </form>
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="addUserAuthDialog">
    <form id="addUserAuthForm" lay-filter="addUserAuthForm" class="layui-form model-form">
        <input type="hidden" name="id">
        <div class="layui-form-item">
            <label class="layui-form-label">真实姓名
            </label>
            <div class="layui-input-block">
                <input name="real_name" placeholder="真实姓名最多100个字符" class="layui-input"
                       lay-verType="tips" lay-verify="real_name" autocomplete="off" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">身份证号码</label>
            <div class="layui-input-block">
                <input name="id_card" placeholder="身份证号码最多100个字符" class="layui-input"
                       lay-verType="tips" lay-verify="id_card" autocomplete="off" required/>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn" lay-filter="addUserAuthSubmit" lay-submit>保存</button>
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </form>
</script>

<!-- js部分 -->
<script type="text/javascript" src="__TPL_RESOURCE_BACKEND__/libs/layui/layui.js"></script>
<script type="text/javascript" src="__TPL_RESOURCE_BACKEND__/js/common.js"></script>
<script>
    layui.use(['layer', 'form', 'table', 'admin', 'laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var admin = layui.admin;
        var laydate = layui.laydate;

        const startTime = new Date(new Date().setDate(new Date().getDate() - 30));
        startTime.setHours(0, 0, 0, 0);
        var startDate = startTime.toISOString().split('T')[0] + ' 00:00:00';

        const endTime = new Date(new Date().setDate(new Date().getDate() + 2));
        endTime.setHours(0, 0, 0, 0);
        var endDate = endTime.toISOString().split('T')[0] + ' 00:00:00';

        laydate.render({
            elem: '#startDate',
            type: 'datetime',
            value: startDate
        });

        laydate.render({
            elem: '#endDate',
            type: 'datetime',
            value: endDate
        });

        /* 渲染表格 */
        var insTb = table.render({
            elem: '#test',
            url: "{{:url('User/index')}}",
            page: {
                limit: 20
            },
            where: {
                start_date: startDate,
                end_date: endDate
            },
            method: 'post',
            contentType: 'application/json',
            toolbar: ['<p>',
                '<button lay-event="add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>&nbsp;',
                '</p>'].join(''),
            cols: [[
                {field: 'id', title: 'ID', width: 60},
                {field: 'account', title: '账户'},
                {field: 'mobile', title: '手机号码'},
                {field: 'level_name_txt', title: '会员等级', width: 90},
                {field: 'balance', title: '余额'},
                {field: 'rixibao_money', title: '日息宝', width: 100},
                {
                    title: '状态', templet: function (d) {
                        return [
                            '<span style="color: #5FB878;">正常</span>',
                            '<span style="color: #C2C2C2;">冻结</span>',
                        ][d.status];
                    }, align: 'center', width: 80
                },
                {
                    title: '时间&IP', templet: function (d) {
                        return '<span>注册时间：' + d.created_at + '</span><br>' +
                            '<span>最后登录：' + d.last_logined_at + '</span><br>' +
                            '<span>IP：' + d.ip + '</span>'
                    }, align: 'left', width: 240
                },
                {title: '操作', toolbar: '#barDemo', width: 300}
            ]]
        });

        /* 表格搜索 */
        form.on('submit(search)', function (data) {
            insTb.reload({where: data.field, page: {curr: 1}});
            return false;
        });

        /* 表格工具条点击事件 */
        table.on('tool(test)', function (obj) {
            if (obj.event === 'recharge') { //充值
                showSaveRechargeModel(obj.data);
            } else if (obj.event === 'reduce') {//扣款
                showSaveReduceModel(obj.data);
            } else if (obj.event === 'editBankCard') {//修改银行卡
                showSaveBankCardModel(obj.data);
            } else if (obj.event === 'delBankCard') {//删除银行卡
                doDelBankCard(obj);
            } else if (obj.event === 'del') { //删除用户信息
                doDel(obj);
            } else if (obj.event === 'thaw') { //冻结
                editStatus(obj, 1);
            } else if (obj.event === 'freeze') { //解冻
                editStatus(obj, 0);
            } else if (obj.event === 'rixibao') { //修改日息宝金额
                showSaveRixibaoModel(obj.data);
            } else if (obj.event === 'edit') { //修改用户信息
                showSaveUserModel(obj.data);
            } else if (obj.event === 'addUserAuth') { //添加实名认证
                showAddUserAuthModel(obj.data);
            }
        });

        /* 表格头工具栏点击事件 */
        table.on('toolbar(test)', function (obj) {
            if (obj.event === 'add') { // 添加
                showAddUserModel();
            }
        });

        /* 显示充值弹窗 */
        function showSaveRechargeModel(mData) {
            admin.open({
                type: 1,
                title: '用户充值',
                area: ['500px', '200px'],
                maxmin: true,
                resize: true,
                content: $('#saveRechargeDialog').html(),
                success: function (layero, dIndex) {
                    form.val('saveRechargeForm', {
                        id: mData.id
                    });
                    var url = "{{:url('User/recharge')}}";
                    // 表单提交事件
                    form.on('submit(saveRechargeSubmit)', function (data) {
                        var loading = layer.load(3);

                        $.ajax({
                            url: url,
                            type: 'post',
                            data: data.field,
                            success: function (res) {
                                if (res.code != 0) {
                                    layer.msg(res.msg, {icon: 5, time: 1000});
                                } else {
                                    layer.close(dIndex);
                                    layer.msg(res.msg, {icon: 1, time: 1500});
                                    insTb.reload();
                                }
                                layer.close(loading);
                            }, error: function () {
                                layer.msg('网络错误请稍后重试', {icon: 5, time: 1000});
                                layer.close(loading);
                            }
                        });
                        return false;
                    });
                }
            });
        }

        /* 显示扣款弹窗 */
        function showSaveReduceModel(mData) {
            admin.open({
                type: 1,
                title: '用户扣款',
                area: ['500px', '200px'],
                maxmin: true,
                resize: true,
                content: $('#saveReduceDialog').html(),
                success: function (layero, dIndex) {
                    form.val('saveReduceForm', {
                        id: mData.id
                    });
                    var url = "{{:url('User/reduce')}}";
                    // 表单提交事件
                    form.on('submit(saveReduceSubmit)', function (data) {
                        var loading = layer.load(3);

                        $.ajax({
                            url: url,
                            type: 'post',
                            data: data.field,
                            success: function (res) {
                                if (res.code != 0) {
                                    layer.msg(res.msg, {icon: 5, time: 1000});
                                } else {
                                    layer.close(dIndex);
                                    layer.msg(res.msg, {icon: 1, time: 1500});
                                    insTb.reload();
                                }
                                layer.close(loading);
                            }, error: function () {
                                layer.msg('网络错误请稍后重试', {icon: 5, time: 1000});
                                layer.close(loading);
                            }
                        });
                        return false;
                    });
                }
            });
        }

        /* 显示日息宝弹窗 */
        function showSaveRixibaoModel(mData) {
            admin.open({
                type: 1,
                title: '修改日息宝金额',
                area: ['500px', '200px'],
                maxmin: true,
                resize: true,
                content: $('#saveRixibaoDialog').html(),
                success: function (layero, dIndex) {
                    form.val('saveRixibaoForm', {
                        id: mData.id,
                        money: mData.rixibao_money
                    });
                    var url = "{{:url('User/editRixibaoMoney')}}";
                    // 表单提交事件
                    form.on('submit(saveRixibaoSubmit)', function (data) {
                        var loading = layer.load(3);

                        $.ajax({
                            url: url,
                            type: 'post',
                            data: data.field,
                            success: function (res) {
                                if (res.code != 0) {
                                    layer.msg(res.msg, {icon: 5, time: 1000});
                                } else {
                                    layer.close(dIndex);
                                    layer.msg(res.msg, {icon: 1, time: 1500});
                                    insTb.reload();
                                }
                                layer.close(loading);
                            }, error: function () {
                                layer.msg('网络错误请稍后重试', {icon: 5, time: 1000});
                                layer.close(loading);
                            }
                        });
                        return false;
                    });
                }
            });
        }

        /* 显示用户弹窗 */
        function showSaveUserModel(mData) {
            admin.open({
                type: 1,
                title: '修改用户',
                area: ['700px', '600px'],
                maxmin: true,
                resize: true,
                content: $('#saveUserDialog').html(),
                success: function (layero, dIndex) {
                    form.val('saveUserForm', {
                        id: mData.id,
                        account: mData.account,
                        mobile: mData.mobile,
                        level_id: mData.level_id,
                        status: mData.status
                    });

                    // 自动最大化弹窗
                    layer.full(dIndex);

                    // 表单提交事件
                    form.on('submit(saveUserSubmit)', function (data) {
                        var loading = layer.load(3);
                        $.ajax({
                            url: "{{:url('User/edit')}}",
                            type: 'post',
                            data: data.field,
                            success: function (res) {
                                if (res.code != 0) {
                                    layer.msg(res.msg, {icon: 5, time: 1000});
                                } else {
                                    layer.close(dIndex);
                                    layer.msg(res.msg, {icon: 1, time: 1500});
                                    insTb.reload();
                                }
                                layer.close(loading);
                            }, error: function () {
                                layer.msg('网络错误请稍后重试', {icon: 5, time: 1000});
                                layer.close(loading);
                            }
                        });
                        return false;
                    });
                }
            });
        }

        /* 显示创建用户弹窗 */
        function showAddUserModel(mData) {
            admin.open({
                type: 1,
                title: '添加用户',
                area: ['700px', '600px'],
                maxmin: true,
                resize: true,
                content: $('#addUserDialog').html(),
                success: function (layero, dIndex) {
                    form.val('addUserForm', mData);

                    // 自动最大化弹窗
                    layer.full(dIndex);

                    // 表单提交事件
                    form.on('submit(addUserSubmit)', function (data) {
                        var loading = layer.load(3);
                        $.ajax({
                            url: "{{:url('User/add')}}",
                            type: 'post',
                            data: data.field,
                            success: function (res) {
                                if (res.code != 0) {
                                    layer.msg(res.msg, {icon: 5, time: 1000});
                                } else {
                                    layer.close(dIndex);
                                    layer.msg(res.msg, {icon: 1, time: 1500});
                                    insTb.reload();
                                }
                                layer.close(loading);
                            }, error: function () {
                                layer.msg('网络错误请稍后重试', {icon: 5, time: 1000});
                                layer.close(loading);
                            }
                        });
                        return false;
                    });
                }
            });
        }

        /* 显示创建用户实名认证弹窗 */
        function showAddUserAuthModel(mData) {
            var loading = layer.load(3);
            $.ajax({
                url: "{{:url('User/addUserAuth')}}",
                type: 'get',
                data: {id: mData.id},
                success: function (res) {
                    if (res.code != 0) {
                        layer.msg(res.msg, {icon: 5, time: 1000});
                    } else {
                        admin.open({
                            type: 1,
                            title: '添加用户实名认证',
                            area: ['600px', '300px'],
                            maxmin: true,
                            resize: true,
                            content: $('#addUserAuthDialog').html(),
                            success: function (layero, dIndex) {
                                form.val('addUserAuthForm', mData);

                                // 表单提交事件
                                form.on('submit(addUserAuthSubmit)', function (data) {
                                    var loading = layer.load(3);
                                    $.ajax({
                                        url: "{{:url('User/addUserAuth')}}",
                                        type: 'post',
                                        data: data.field,
                                        success: function (res) {
                                            if (res.code != 0) {
                                                layer.msg(res.msg, {icon: 5, time: 1000});
                                            } else {
                                                layer.close(dIndex);
                                                layer.msg(res.msg, {icon: 1, time: 1500});
                                                insTb.reload();
                                            }
                                            layer.close(loading);
                                        }, error: function () {
                                            layer.msg('网络错误请稍后重试', {icon: 5, time: 1000});
                                            layer.close(loading);
                                        }
                                    });
                                    return false;
                                });
                            }
                        });
                    }
                    layer.close(loading);
                }, error: function () {
                    layer.msg('网络错误请稍后重试', {icon: 5, time: 1000});
                    layer.close(loading);
                }
            });
        }

        /* 冻结、解冻账户 */
        function editStatus(obj, status) {
            layer.confirm('确定要处理选中数据吗？', {
                skin: 'layui-layer-admin',
                shade: .1
            }, function (i) {
                layer.close(i);
                var loading = layer.load(3);
                $.ajax({
                    url: "{{:url('User/editStatus')}}",
                    type: 'post',
                    data: {id: obj.data.id, status: status},
                    success: function (res) {
                        if (res.code != 0) {
                            layer.msg(res.msg, {icon: 5, time: 1000});
                        } else {
                            layer.msg(res.msg, {icon: 1, time: 1500});
                            insTb.reload();
                        }
                        layer.close(loading);
                    }, error: function () {
                        layer.msg('网络错误请稍后重试', {icon: 5, time: 1000});
                        layer.close(loading);
                    }
                });
                return false;
            });
        }

        /* 删除 */
        function doDel(obj) {
            layer.confirm('确定要删除选中数据吗？', {
                skin: 'layui-layer-admin',
                shade: .1
            }, function (i) {
                layer.close(i);
                var loading = layer.load(3);
                $.ajax({
                    url: "{{:url('User/del')}}",
                    type: 'post',
                    data: {id: obj.data.id},
                    success: function (res) {
                        if (res.code != 0) {
                            layer.msg(res.msg, {icon: 5, time: 1000});
                        } else {
                            layer.msg(res.msg, {icon: 1, time: 1500});
                            insTb.reload();
                        }
                        layer.close(loading);
                    }, error: function () {
                        layer.msg('网络错误请稍后重试', {icon: 5, time: 1000});
                        layer.close(loading);
                    }
                });
                return false;
            });
        }

        /* 显示修改银行卡弹窗 */
        function showSaveBankCardModel(mData) {
            var loading = layer.load(3);
            $.ajax({
                url: "{{:url('User/editBankCard')}}",
                type: 'get',
                data: {id: mData.id},
                success: function (res) {
                    if (res.code != 0) {
                        layer.msg(res.msg, {icon: 5, time: 1000});
                    } else {
                        admin.open({
                            type: 1,
                            title: '修改银行卡用户',
                            area: ['500px', '420px'],
                            maxmin: true,
                            resize: true,
                            content: $('#saveBankCardDialog').html(),
                            success: function (layero, dIndex) {
                                form.val('saveBankCardForm', res.data);
                                // 表单提交事件
                                form.on('submit(saveBankCardSubmit)', function (data) {
                                    var loading = layer.load(3);
                                    $.ajax({
                                        url: "{{:url('User/editBankCard')}}",
                                        type: 'post',
                                        data: data.field,
                                        success: function (res) {
                                            if (res.code != 0) {
                                                layer.msg(res.msg, {icon: 5, time: 1000});
                                            } else {
                                                layer.close(dIndex);
                                                layer.msg(res.msg, {icon: 1, time: 1500});
                                                insTb.reload();
                                            }
                                            layer.close(loading);
                                        }, error: function () {
                                            layer.msg('网络错误请稍后重试', {icon: 5, time: 1000});
                                            layer.close(loading);
                                        }
                                    });
                                    return false;
                                });

                                return false;
                            }
                        });
                    }
                    layer.close(loading);
                }, error: function () {
                    layer.msg('网络错误请稍后重试', {icon: 5, time: 1000});
                    layer.close(loading);
                }
            });
        }

        /* 删除银行卡 */
        function doDelBankCard(obj) {
            layer.confirm('确定要删除该用户的银行卡吗？', {
                skin: 'layui-layer-admin',
                shade: .1
            }, function (i) {
                layer.close(i);
                var loading = layer.load(3);
                $.ajax({
                    url: "{{:url('User/delBankCard')}}",
                    type: 'post',
                    data: {id: obj.data.id},
                    success: function (res) {
                        if (res.code != 0) {
                            layer.msg(res.msg, {icon: 5, time: 1000});
                        } else {
                            layer.msg(res.msg, {icon: 1, time: 1500});
                            insTb.reload();
                        }
                        layer.close(loading);
                    }, error: function () {
                        layer.msg('网络错误请稍后重试', {icon: 5, time: 1000});
                        layer.close(loading);
                    }
                });
                return false;
            });
        }
    });
</script>
</body>
</html>
